Skip to content

feat(cockpit): Phase 2 live per-worker progress events - #58

Merged
robercano-ghbot merged 3 commits into
mainfrom
feat/issue-52-live-progress-events
Jul 6, 2026
Merged

feat(cockpit): Phase 2 live per-worker progress events#58
robercano-ghbot merged 3 commits into
mainfrom
feat/issue-52-live-progress-events

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Summary

Cockpit Phase 2 (issue #52): live per-worker progress on top of the Phase 1 dashboard (#51). Observability only — no change to gate enforcement or review consensus, purely additive.

What's new

  • .claude/scripts/log-event.sh (new) — best-effort helper agents call at each phase transition. Appends one JSON line to .claude/state/events.jsonl (gitignored, runtime-only). Schema: ts (ISO-8601 UTC), role, model, task, phase, lens, detail. JSON is node-built (safe escaping). Honors CLAUDE_EVENTS_FILE override. Rotation: caps the log to the last ${EVENTS_MAX_LINES:-2000} lines via temp-file + atomic rename, so unattended multi-day runs stay bounded. Always exits 0 — it can never break the loop.
  • .claude/scripts/cockpit.sh — new "Live worker progress" section: reads the JSONL (default path, --fixtures <dir>/events.jsonl offline seam, CLAUDE_EVENTS_FILE override), dedups to the latest event per (role, task), renders role/task/model/phase/lens/updated. Tolerates blank/malformed/array lines (skipped, never crashes), shows "no active workers" when empty/missing, and still exits 0 on every degraded path — same contract as Phase 1. Re-read-on-refresh only: no daemon, no tail -f, no persistent server.
  • .claude/agents/{orchestrator,implementer,reviewer}.md — each gains a short "Progress events" instruction to call log-event.sh at its phase transitions (scoped / implementing / gate-running / reviewing / done), explicitly best-effort and non-gating.

Tests

  • .claude/scripts/log-event.test.sh (new) — 11 checks: JSONL validity, field round-trip, quote/backslash/</script> escaping, empty-optional defaults, rotation keeps exactly the last N (and the most recent), boundary at exactly N, best-effort exit 0 on odd/dangling args.
  • .claude/scripts/cockpit.test.sh — 36 checks (existing + new): live section present, dedup-to-latest, second worker in a different phase, malformed/blank/array-line tolerance still exits 0 with the good row surviving, array line yields no phantom row (exact row count), and live-section field HTML-escaping (stored-XSS guard).

Gates (self-adapter)

  • GATES_FILE=.claude/self/gates.json bash .claude/scripts/gate.sh build|lint|test — all pass
  • bash .claude/scripts/cockpit.test.sh — 36/36
  • bash .claude/scripts/log-event.test.sh — 11/11

Review

Reviewed under the self-adapter lenses correctness + tests (consensus: all). Both approve; the tests lens verified every new assertion has teeth via targeted code mutations.

closes #52

🤖 Generated with Claude Code

robercano and others added 3 commits July 6, 2026 17:17
Add log-event.sh, a tiny best-effort observability helper the orchestrator/
implementer/reviewer agents call at each phase transition. It appends one
JSONL event (ts, role, model, task, phase, lens, detail) to
.claude/state/events.jsonl (gitignored, CLAUDE_EVENTS_FILE-overridable),
built with node for safe escaping, and rotates to the last
EVENTS_MAX_LINES (default 2000) lines via temp-file + atomic move.

Extend cockpit.sh with a "Live worker progress" panel that reads the event
log (or <fixtures>/events.jsonl in --fixtures mode), tolerates malformed
lines, and dedups to each worker's LATEST phase keyed by (role, task).
Degrades to a muted "no active workers" placeholder and never breaks the
script's exit-0 contract, consistent with Phase 1.

Wire the three agent prompts (orchestrator/implementer/reviewer) to log
their phase transitions, explicitly noting this is additive-only
observability that must never affect gate enforcement or review
consensus.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdLbxgUQhEVr6XtFGzBpsY
…rd array lines

- cockpit.sh readEvents(): tighten the object guard to exclude JSON arrays
  (typeof [] === "object" too), which previously produced a phantom worker
  row on a stray array line.
- cockpit.test.sh: fold a malformed JSON line, a blank line, a JSON-array
  line, and an XSS-payload worker (script tag + quote in role) into the
  events fixture. Assert the render still exits 0, a known-good worker row
  still renders, the live table has exactly the legitimate worker count (no
  phantom rows from the array line), and the live section escapes fields
  (raw <script> absent, escaped form present) — mirroring the existing
  issue-title escaping check.
- log-event.test.sh: add a rotation boundary assertion — writing exactly N
  events with EVENTS_MAX_LINES=N leaves exactly N lines, no rotation at the
  boundary.

Addresses reviewer feedback (tests lens rejection; correctness lens
low-severity finding) on issue #52.
@robercano-ghbot
robercano-ghbot merged commit a46f3e9 into main Jul 6, 2026
9 checks passed
@robercano-ghbot
robercano-ghbot deleted the feat/issue-52-live-progress-events branch July 6, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cockpit Phase 2: live per-worker progress events (depends on #51)

2 participants